<template>
	<view>
		<view class="content_wrap" style="margin-top: 20upx;">
			<view class="content row">
				<span>姓名</span>
				<span class="flex_one"></span>
				<input type="text" v-model="name" :placeholder="placeholderName" placeholder-class="phclass"/>
			</view>
		</view>
		
		<view class="content_wrap">
			<view class="content row">
				<span>证件类型</span>
				<span class="flex_one"></span>
				<span>身份证</span>
			</view>
		</view>
		
		<view class="content_wrap">
			<view class="content row" style="border-bottom: none;">
				<span>证件号</span>
				<span class="flex_one"></span>
				<input type="text" v-model="identity" maxlength="18"
					placeholder="请输入证件号" placeholder-class="phclass"/>
			</view>
		</view>
		
		<view class="bottom_btn row_center" @click="goToNext">
			<span class="flex_one" :class="{'active': (name && identity)}">下一步</span>
		</view>
		
	</view>
</template>

<script>
	import { BASE_URL,baseinfo,checkreal } from '@/utils/api'
	
	export default {
		data() {
			return {
				isActive: false,
				placeholderName: '',
				identity: '',
				name: ''
			}
		},
		methods: {
			async baseinfo(){
				let res = await baseinfo();
				if(res.code == 1){
					let name = res.data.realName;
					name = "*"+name.substring(1, name.length);
					this.placeholderName = name+"(请输入完整姓名)";
				}
			},
			async checkreal(){
				let params = {
					cardNo: this.identity,
					realName: this.name
				};
				let res = await checkreal(params);
				if(res.code == 1){
					uni.navigateTo({
						url:'/pages/set_pay_pwd/set_pay_pwd?name='+this.name+"&identity="+this.identity
					})
				}else{
					uni.showToast({
						icon: 'none',
						duration:2000,
						title:res.message
					});
				}
			},
			goToNext(){
				if(!this.name){
					uni.showToast({
						icon: 'none',
						duration:2000,
						title:'请输入姓名'
					});
					return;
				}
				
				if(!this.identity){
					uni.showToast({
						icon: 'none',
						duration:2000,
						title:'请输入身份证号'
					});
					return;
				}
				this.checkreal();
			}
		},
		onLoad() {
			this.baseinfo();
			// let name = uni.getStorageSync("bankParams").name;
			// this.placeholderName = "*"+name.substring(1, name.length)+"(请输入完整姓名)";
		}
	}
</script>

<style>
	page{background: #F1F1F1;}
.content_wrap{padding-left: 27upx; background: #FFFFFF; color: #333333; font-size: 32upx;}
.content_wrap .content{height: 100upx; border-bottom: solid 2upx #E6E6E6; padding-right: 30upx;}
.content_wrap .content image{height: 20upx; width: 15upx; margin-right: 5upx;}
.content_wrap .content input{text-align: right;}

.bottom_btn{padding: 0upx 30upx; margin-top: 60upx;}
.bottom_btn span{background: #CCCCCC; color: #FFFFFF; font-size: 32upx; height: 94upx; line-height: 94upx; text-align: center;
	font-weight: bold;border-radius: 12upx;}
.active{background: #FFCA0A!important; color: #333333!important;}

	
</style>
